package com.camera.controller;


import com.camera.common.Result;
import com.camera.common.ResultData;
import com.camera.pojo.CameraDTO;
import com.camera.service.CameraService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.nio.file.Files;

/**
 * @Classname CameraController
 * @Description TODO
 * @Date 2025/3/10 13:52
 * @Created by xxx
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/collect_camera")
public class CameraController {

    @Autowired
    private CameraService cameraService;

    @PostMapping
    public Result collectCamera(@RequestBody CameraDTO cameraDTO) {
        log.info("collectCamera: {}", cameraDTO);
        try {
            ResultData resultData = cameraService.getType(cameraDTO);
            resultData.setOrderID(cameraDTO.getOrderID());
            return Result.success(resultData);

        } catch (Exception e) {
            ResultData data = new ResultData();
            data.setImageID(cameraDTO.getImageID());
            return Result.error(data, e.getMessage());
        }
    }

}
